-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CI: Overhaul static checks to use pre-commit
#91597
CI: Overhaul static checks to use pre-commit
#91597
Conversation
b626e7e
to
d9df5fc
Compare
Thanks for working on this! That's amazing. I have yet to review the code properly, but some minor issues found when testing on Linux with
|
Found by apply the file_format checks again via godotengine#91597.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed the code, looks really good.
- name: Spell checks via codespell | ||
if: github.event_name == 'pull_request' && env.CHANGED_FILES != '' | ||
uses: codespell-project/actions-codespell@v2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noting that we'll miss one feature here, which is that this action provides a problem matcher in the GitHub diff view.
But in my experience most contributors don't seem to notice it (it's only visible in diff view, not on the PR itself), and the action was lacking in other configuration aspects so I think the tradeoffs are fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pre-commit should be set to output a git-diff log if any checks fail or changes are made, so it won't be that much of a loss.
.pre-commit-config.yaml
Outdated
- repo: https://github.com/pre-commit/mirrors-eslint | ||
rev: v8.46.0 | ||
hooks: | ||
- id: eslint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these hooks have the same id
, is that intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is intentional, yes. They're all pulling from the same original hook implementing eslint
, but it's called multiple times to replicate the multiple eslint checks we use. That's why name
is different for each one, to differentiate the different checks during output.
BTW, if you want to have a look at how we could solve the problem those two PRs aimed to address (users not having |
d9df5fc
to
98052e2
Compare
I meant to tackle this possibly in a follow up PR, none of the two proposed solutions seem to work well cross-platform currently. The current commit needs adding executable permission to files to work on Linux:
But based on #90662 (review) this might not work on macOS. |
98052e2
to
df969ff
Compare
I'll leave the |
Beautiful:
|
Thanks! Great refactor 🎉 |
Found by apply the file_format checks again via godotengine#91597.
It looks like this broke CI and no style checks are run at all, see: Which has changed files but skips them I suspect this is because it can't detect the files since there are no changed files |
Then it probably needs that git diff logic passed to it after all, or something similar. Should be an easy fix either way, I'll get something up later today |
@Repiteo Hi, would you be so kind as to take another look at https://github.com/godotengine/godot/pull/91863/checks
Is it possible for pre-commit to run |
Found by apply the file_format checks again via godotengine#91597.
Found by apply the file_format checks again via godotengine#91597.
1
Consolidates (almost) every single
static_checks
function/command intopre-commit
directly. This has the benefit of adding these static checks as proper pre-commit hooks to the repo itself, so more issues have the potential to be caught well ahead of time. If possible, existingmisc
scripts were either replaced with a more parsable python equivalent, or removed entirely if a hook repo exists to achieve the same goal.Only three exceptions remain that are still checked via
static_checks
:gitignore_check.sh
,pytest
, andxmllint
.gitignore_check.sh
is pretty specific to the workflow of that file specifically, so it's most sensible to keep as-is.xmllint
technically has a hook available, but it requires docker & that's not nearly as likely for a user to have compared to npm/dotnet.pytest
actually would've worked just fine, but based off a conversation2 when I attempted to add it to pre-commit, it isn't a good candidate for a pre-commit so I'll leave it as-is.Footnotes
https://github.com/godotengine/godot/pull/91417#pullrequestreview-2034011566 ↩
https://github.com/pre-commit/pre-commit.com/pull/960 ↩